<template>
  <view class="page">
    <Search></Search>
    <view class="menu">
      <Menu></Menu>
    </view>
    <view class="menu">
      <!-- <Swiper></Swiper> -->
    </view>
    <view class="equity">
      <Equitys></Equitys>
    </view>
    <!--   <view class="fuli">
            <Fuli></Fuli>
        </view>
        <view class="shouxuan">
            <view class="shouxuan-1"> 目标年化收益率6.00% </view>
            <view class="shouxuan-2">追求稳健 无需选择 止盈提醒 </view>
            <view class="but"> 立即查看 </view>
        </view> -->
    <!--  -->
    <view class="xinwennew">
      <view class="gun">
        <u-notice-bar
          mode="horizontal"
          type="primary"
          :more-icon="true"
          :close-icon="true"
          :list="newList"
        >
        </u-notice-bar>
      </view>
      <view class="center">
        <view class="title">
          <text>实时新闻</text>
        </view>
        <view
          class="box"
          v-for="item in showNews"
          :key="item.newsId"
          style="margin-top: 20rpx; border-bottom: 1px solid #fafafa"
        >
          <view class="top">
            <view class="">
              {{ item.newsTitle }}
            </view>
            <view class="left">
              {{ item.newsContent }}
            </view>
          </view>
          <view class="bottom">
            <text>为你推荐</text>
            <text>...</text>
          </view>
        </view>
      </view>
    </view>
    <view class="licai">
      <Conduct>s</Conduct>
    </view>
    <view class="bangdan">
      <Bandna></Bandna>
    </view>
    <view class="tuijian">
      <Tuijian></Tuijian>
    </view>
    <view class="daka">
      <Daka></Daka>
    </view>
	<!-- 底部导航栏 -->
	<u-tabbar :list="tabbar" :mid-button="true"></u-tabbar>
  </view>
</template>

<script>
import { createNamespacedHelpers } from "vuex";
const { mapActions, mapState } = createNamespacedHelpers("message");
const { mapActions: userMapActions } = createNamespacedHelpers("user");

import Search from "../../components/index/Search.vue";
import Menu from "../../components/index/menu.vue";
import Swiper from "../../components/index/swiper.vue";
import Equitys from "../../components/index/equity.vue";
import Fuli from "../../components/index/fuli.vue";
import Conduct from "../../components/index/conduct.vue";
import Bandna from "../../components/index/bangdna.vue";
import Tuijian from "../../components/index/tuijian.vue";
import Daka from "../../components/index/daka.vue";
export default {
  components: {
    Search,
    Menu,
    Swiper,
    Equitys,
    Fuli,
    Conduct,
    Bandna,
    Tuijian,
    Daka,
  },
  created() {
    this.getnewsShow();
    this.getcaijinnews();
    this.getUserData();
    this.userDetail();
  },onShow(){
		
		
		},
  mounted() {},
  data() {
    return {
		tabbar: '',
      list: [
        "黄金 | 实时金价  361.1 -8.3 -2.66%大大撒旦顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶阿三顶顶顶顶顶顶顶顶顶顶顶顶顶",
        "黄金 | 实时金价  361.1 -8.3 -2.66%",
        "黄金 | 实时金价  361.1 -8.3 -2.66%",
      ],
    };
  },
  computed: {
    ...mapState(["showNews", "showFinancialInformation"]),

    //获取所有财经咨询新闻并纯在listlimian1//滚动通知
    newList() {
      this.list = this.showNews;
      return this.list.map((a) => a.newsContent + "");
    },
  },
  onLoad() {
    this.userAuthenticationStatusDta()
    console.log(15416);
	/**
	 * 示例中为每个tabbar页面都写了一遍tabbar变量，您可以将tabbar数组写入到vuex中，这样可以全局引用
	 */
	this.tabbar = [{
			iconPath: "home",
			selectedIconPath: "home-fill",
			text: '借贷',
			count: 0,
			isDot: true,
			customIcon: false,
			pagePath: "/pages/lending/lending"
		},
		{
			iconPath: "red-packet",
			selectedIconPath: "red-packet-fill",
			text: '财富',
			customIcon: false,
			pagePath: "/pages/riches/riches"
		},
		{
			iconPath: "https://cdn.uviewui.com/uview/common/min_button.png",
			selectedIconPath: "https://cdn.uviewui.com/uview/common/min_button_select.png",
			text: '首页',
			midButton: true,
			customIcon: false,
			pagePath: "/pages/index/index"
		},
		{
			iconPath: "bell",
			selectedIconPath: "bell-fill",
			text: '财顾',
			customIcon: false,
			pagePath: "/pages/adviser/adviser"
		},
		{
			iconPath: "account",
			selectedIconPath: "account-fill",
			text: '我的',
			count: 0,
			isDot: false,
			customIcon: false,
			pagePath: "/pages/mycenter/mycenter"
		},
	]
  },
  methods: {
    ...mapActions(["getAllShowNews", "getAllShowFinancialInformation"]),
    ...userMapActions(["getUser", "allUserinfo",'userAuthenticationStatus']),
    // 获取用户身份认证
    async userAuthenticationStatusDta() {
      const data = await this.userAuthenticationStatus();
      console.log(data,'身份认证');
      uni.setStorageSync("userAuthenticationStatus", data.data);
     
    },
    // 获取用户风险等级
    async userDetail() {
      const data = await this.allUserinfo();
      console.log(data,'风险');
      uni.setStorageSync("userAssessmentLevel", data.data.userAssessmentLevel);
      console.log(data, "lllll");
    },
    //获取展示新闻
    async getnewsShow() {
      await this.getAllShowNews();
    },
    //获取财经咨询新闻
    async getcaijinnews() {
      await this.getAllShowFinancialInformation();
    },
    async getUserData() {
      const data = await this.getUser();
      if (data) {
        uni.setStorageSync("userId", data.data.userId);
        uni.setStorageSync("userTel", data.data.userTel);
      }
      console.log(data, "data");
    },
	//下拉刷新
	async onPullDownRefresh() {
		console.log('refresh');
		// setTimeout(function () {
		//     uni.stopPullDownRefresh();
		// }, 1000);
		this.getnewsShow();
		// this.getcaijinnews();
		// // this.getUserData();
		// this.userDetail();
		setTimeout(function() {
			uni.stopPullDownRefresh(); //停止下拉刷新动画
		}, 1000);
	}
  },
};
</script>

<style lang="scss" scoped>
.page {
  background-color: #fafafa;
}
.daka {
  margin-top: 40rpx;
  box-sizing: border-box;
  margin: 24rpx;
  border-radius: 30rpx;
}
.tuijian {
  margin-top: 40rpx;
  box-sizing: border-box;
  margin: 24rpx;
  border-radius: 30rpx;
}
.bangdan {
  margin-top: 20pt;
  box-sizing: border-box;
  margin: 12pt;
  border-radius: 30rpx;
}
.licai {
  margin-top: 20pt;
  box-sizing: border-box;
  margin: 12pt;
  border-radius: 30rpx;
}
.shouxuan {
  margin-top: 20pt;
  box-sizing: border-box;
  height: 340rpx;
  font-size: 13px;
  margin: 12pt;
  border-radius: 30rpx;
  // background-image: url(../../static/iamges/shouxuanx.png);
  background-size: 100% 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  align-items: center;
  position: relative;
  .but {
    position: absolute;
    border-radius: 30rpx;
    height: 64rpx;
    width: 250rpx;
    background-color: #ffffff;
    color: #ff4658;
    font-size: 28rpx;
    text-align: center;
    line-height: 64rpx;
    font-weight: 700;
    bottom: 24rpx;
  }
  .shouxuan-1 {
    color: #ffffff;
    font-size: 52rpx;
  }
  .shouxuan-2 {
    font-size: 24rpx;
    color: #ffcfcf;
  }
}
.fuli {
  margin-top: 20pt;
  box-sizing: border-box;
  height: 274rpx;
  font-size: 13px;
  margin: 12pt;
  border-radius: 30rpx;
}
.menu {
  margin-top: 20pt;
  margin: 12pt;
  margin: 12pt;
  box-sizing: border-box;
  background-color: white;
  border-radius: 30rpx;
}
.equity {
  background-color: #ffffff;
  margin-top: 20pt;
  box-sizing: border-box;
  height: 274rpx;
  font-size: 13px;
  margin: 12pt;
  border-radius: 30rpx;
}
.xinwennew {
  padding: 10rpx 24rpx;
  .center {
    //border: 1px solid red;
    background-color: #ffffff;
    border-radius: 15rpx;
    padding: 30rpx 15rpx;
    .title {
      font-weight: 800;
      font-size: 32rpx;
    }
    .top {
      margin-top: 15rpx;
      .left {
        font-size: 26rpx;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
        font-weight: 300;
        margin-top: 20rpx;
      }
    }
    .bottom {
      margin-top: 20rpx;
      display: flex;
      justify-content: space-between;
    }
  }
}
</style>
